var e = getApp();

Page({
    data: {
        rewardMoneyBtn: !1
    },
    onLoad: function(t) {
        if (t.id && this.setData({
            id: t.id
        }), t.scene) {
            var a = decodeURIComponent(t.scene);
            if (a) {
                var i = [];
                i = a.split(",");
                for (var d = 0; d < i.length; d++) {
                    var s;
                    s = i[d].split("="), console.log(s), "id" == s[0] && this.setData({
                        id: s[1]
                    }), "mid" == s[0] && e._setMid(s[1]);
                }
            }
        }
        this.getData();
    },
    change: function(e) {
        var t = e.detail.value;
        if (console.log(t), t == this.data.result.familyCard.id) try {
            this.data.result.familyCard.checked = !0, this.data.result.onceCard.checked = !1, 
            this.data.result.timeCard.checked = !1;
        } catch (e) {
            console.log(e);
        } else if (t == this.data.result.onceCard.id) try {
            this.data.result.familyCard.checked = !1, this.data.result.onceCard.checked = !0, 
            this.data.result.timeCard.checked = !1;
        } catch (e) {
            console.log(e);
        } else if (t == this.data.result.timeCard.id) try {
            this.data.result.familyCard.checked = !1, this.data.result.onceCard.checked = !1, 
            this.data.result.timeCard.checked = !0;
        } catch (e) {
            console.log(e);
        } else {
            try {
                this.data.result.familyCard.checked = !1, this.data.result.onceCard.checked = !1, 
                this.data.result.timeCard.checked = !1;
            } catch (e) {
                console.log(e);
            }
            for (var a = 0; a < this.data.result.familyMemberCard.length; a++) t == this.data.result.familyMemberCard[a].id ? this.data.result.familyMemberCard[a].checked = !0 : this.data.result.familyMemberCard[a].checked = !1;
        }
        this.setData({
            result: this.data.result,
            select_un: t
        });
    },
    onClose: function() {
        this.setData({
            rewardMoneyBtn: !1
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    confirm: function() {
        var t = {
            device_id: this.data.id,
            card_id: this.data.select_un
        }, a = this, i = e.getNetAddresss("plugin.energy-cabin.frontend.use-device.confirm-use");
        e._getNetWork({
            url: i,
            data: t,
            success: function(e) {
                var t = e.data;
                1 === t.result ? (wx.showToast({
                    title: t.msg,
                    duration: 1e3,
                    icon: "none"
                }), a.getData()) : wx.showToast({
                    title: t.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    },
    getData: function() {
        var t = this, a = {
            device_id: t.data.id
        }, i = e.getNetAddresss("plugin.energy-cabin.frontend.use-device.index");
        e._getNetWork({
            url: i,
            data: a,
            success: function(e) {
                var a = e.data;
                1 === a.result ? (console.log(a), t.setData({
                    result: a.data.memberCard
                }), a.data.member_info) : a.data.status && wx.reLaunch({
                    url: "/packageG/index/index"
                });
            },
            fail: function(e) {
                console.log(e);
            }
        });
    }
});